import { Descriptions } from 'antd'
import { useRecoilValue } from 'recoil'
import { useEffect, useState } from 'react'
import style from './style.module.less'
import IconSvg from '@/components/IconSvg'
import { adminEnum } from '@/store/adminEnumObject'
import { getHospitalInfo } from './service/service'

interface Hospital {
  id: number
  chineseName: null
  englishName: null
  website: null
  username: string
  platformId: number
  password: string
  telphone: string
  phone: string
  email: string
  accountType: number
  provinceId: number
  provinceName: string
  cityId: number
  cityName: string
  areaId: number
  areaName: string
  inpatientWardId: null
  wardName: null
  allAreaName: null
  hospitalName: string
  oneLevelWardName: null
  twoLevelWardName: null
  hospitalCode: number
  unitName: null
  lastLoginDate: string
  createDate: string
  updateDate: string
  createUser: string
  updateUser: string
  status: boolean
  isDeleted: boolean
  loginCount: string
}
export default () => {
  const adminEnumValues: any = useRecoilValue(adminEnum)

  // 存放医院管理员信息
  const [info, setInfo] = useState<Hospital>({} as Hospital)

  // 获取病区对应的医院管理员信息
  const getAdminInfo = async () => {
    const res = await getHospitalInfo()
    if (res && res.code === 200) {
      setInfo(res.data)
    }
  }

  useEffect(() => {
    getAdminInfo()
  }, [])

  return (
    <div className={style.maxBox}>
      <div className={style.examineBox}>
        <div className={style.center}>
          <div className={style.top}>病区管理员信息</div>
          <div className={style.bottom}>
            <div className={style.bottomCenter}>
              <Descriptions column={1} bordered={false} className={style.description}>
                <Descriptions.Item label='用户角色'>{adminEnumValues[info.accountType]}</Descriptions.Item>
                <Descriptions.Item label='姓名'>{info.username}</Descriptions.Item>
                <Descriptions.Item label='绑定邮箱'>{info.email}</Descriptions.Item>
                <Descriptions.Item label='联系电话'>{info.phone}</Descriptions.Item>
              </Descriptions>
            </div>
          </div>
          <div className={style.imageBox}>
            <IconSvg name='examineImage' style={{ width: '100%', height: '100%' }} />
          </div>
        </div>
      </div>
    </div>
  )
}
